package com.huangsm.book.designmodel;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 比较延迟加载和普通加载创建对象的速度
 * @author huang
 * @PACKAGE_NAME com.huangsm.book.designmodel
 * @PROJECT_NAME concurrence
 * @date 2019/2/15
 */
public class ComporeLazyAndCommon {
    public static void main(String[] args) {
        long beign = System.currentTimeMillis();
        ExecutorService executorService = Executors.newFixedThreadPool(5);

        Runnable task=()->{
            for (int i = 0; i < 100000; i++) {
            //Singleton.getInstance();
            //LazySingleton.getInstance();
                StaticSinglton.getInstance();
            }
            System.out.println(System.currentTimeMillis()-beign);
        };
        executorService.execute(task);
    }
}
